package mainServer;

import mainService.MainHttpServer;
import mainService.services.EliminaLogService;
import mainService.services.EliminaUtenteService;
import mainService.services.HttpFileServer;
import mainService.services.InserisciLogService;
import mainService.services.InserisciTaskService;
import mainService.services.InserisciUtenteService;
import mainService.services.LogOperatoreService;
import mainService.services.LogTaskService;
import mainService.services.LogTaskUserService;
import mainService.services.LoginService;
import mainService.services.LogoutService;
import mainService.services.MenuService;
import mainService.services.ModificaPasswordService;
import mainService.services.RegistrazioneService;
import mainService.services.SelectTaskService;
import mainService.services.SintesiDatiUtenteService;
import mainService.services.SintesiTaskProjectService;
import mainService.services.SintesiUsersProjectService;
import server.HTTPServer;

/**
 * Classe principale del server, basata sul componente {@link MainHttpServer} e
 * sul componente {@link HTTPServer}
 * 
 * Prima di far partire il server vengono aggiunti i servizi che sono
 * disponibili.
 * 
 * @author Mattia Grecchi, Daniel Procop
 */
public class MainServiceStarter {

	private static final int port = 4444;

	public static void main(String[] args) {

		MainHttpServer mainServer = new MainHttpServer();

		mainServer.setFileServerService(new HttpFileServer());
		
		
		mainServer.addService("sintesiLogTask", new LogTaskUserService());
		//sintesiLogTask?id_task=
		mainServer.addService("sintesiLogTaskAll", new LogTaskService());
		//sintesiLogTaskAll?id_task=
		mainServer.addService("sintesiLogTaskUtente", new LogTaskUserService("utente"));
		//sintesiLogTaskUtente?id_task=1&id_utente=
		mainServer.addService("login", new LoginService());
		//login?id=001&password=prova
		mainServer.addService("logout", new LogoutService());
		//logout
		mainServer.addService("menuLink", new MenuService());
		//menuLink
		mainServer.addService("sintesiTuttiTask", new SintesiTaskProjectService());
		//sintesiTuttiTask
		mainServer.addService("sintesiTuttiUtenti", new SintesiUsersProjectService());
		//sintesiTuttiUtenti
		mainServer.addService("get_sessiondata", new SintesiDatiUtenteService());
		//get_sessiondata
		mainServer.addService("logOperatore", new LogOperatoreService());
		// logOperatore
		mainServer.addService("logOperatoreUtente", new LogOperatoreService("utente"));
		// logOperatore?username=gianni
		mainServer.addService("registrazione", new RegistrazioneService());
		//registrazione?username=nome&password=prova&nomeprogetto=pr1&descprogetto=prova
		mainServer.addService("add_task", new InserisciTaskService());
		//add_task?name=task&total_hours=8&description=prova
		mainServer.addService("inserisciLog", new InserisciLogService());
		//inserisciLog?data=04/05/2014&ore=8&task=001&description=prova
		mainServer.addService("select_task", new SelectTaskService());
		//select_task?function=
		mainServer.addService("add_operatore", new InserisciUtenteService());
		//add_operatore?username=io&password=prova&role=Code Analist
		mainServer.addService("deleteLog", new EliminaLogService());
		// deleteLog?id_log=;
		mainServer.addService("deleteUtente", new EliminaUtenteService());
		// deleteUtente?username=;
		mainServer.addService("cambioPassword", new ModificaPasswordService());
		//cambioPassword?password=prova&nuovaPassword=prova1
		
		HTTPServer server = new HTTPServer(port, mainServer);
		server.launch();
	}
}